public class BinaryTree {
    static class TreeNode{
        public char val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(char val) {
            this.val = val;
        }
    }

    public TreeNode CreateTree(){
        TreeNode A = new TreeNode('A');
        TreeNode B = new TreeNode('B');
        TreeNode C = new TreeNode('C');
        TreeNode D = new TreeNode('D');
        TreeNode E = new TreeNode('E');
        TreeNode F = new TreeNode('F');

        A.left = B;
        A.right = C;
        B.left = D;
        C.left = E;
        C.right = F;

        return A;
    }

    public void PrevOrder(TreeNode root){//前序遍历
       if(root == null){
           return;
       }
       System.out.print(root.val+" ");
       PrevOrder(root.left);
       PrevOrder(root.right);
    }

    public void InOrder(TreeNode root){//中序遍历
        if(root == null){
            return;
        }
        InOrder(root.left);
        System.out.print(root.val+" ");
        InOrder(root.right);
    }

    public void PostOrder(TreeNode root){//后序遍历
        if(root == null){
            return;
        }
        PostOrder(root.left);
        PostOrder(root.right);
        System.out.print(root.val+" ");
    }
}